package Task10;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[][] board = new int[3][3];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[i].length; j++) {
                board[i][j] = scanner.nextInt();
            }
        }
        System.out.println(checkWon(board));
    }
    public static boolean checkWon(int[][] board) {
        // write code here
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[i].length; j++) {
                if(board[i][j] == 1){
                    //以行来判断列
                    if(j+2 < board[i].length && board[i][j] == board[i][j+1] && board[i][j] == board[i][j+2]){
                        return true;
                    }
                    //以列判断行
                    if(i+2 < board.length && board[i][j] == board[i+1][j] && board[i][j]  == board[i+2][j]){
                        return true;
                    }
                    if( i == j && j + 2 < board[i].length && i + 2 < board.length){
                        if(board[i][j] == board[i + 1][j + 1] && board[i][j] == board[i+2][j+2]){
                            return true;
                        }
                    }else if( j - i == board.length - 1){
                        if(board[i][j] == board[i+1][j-1]&&board[i][j] == board[i+j][j-i]){
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
}
